<?php ob_start(); ?>

<?php header ('Content-type: text/xml; charset=utf-8'); ?>     

<?php include "constants.inc" ?>

<?php include "classes.inc" ?>

<?php session_start(); ?>

<?php


function loadPlayer() {

	

	if (isset($_GET['playerId'])) {

		$playerId = $_GET['playerId'];

	} 

	

	if (isset($_GET['row'])) {

		$row = $_GET['row'];

	}

	

	if (isset($playerId) && is_numeric($playerId) == true) {

        mysql_connect(DB_SERVER, DB_USER, DB_PWD);

    	mysql_select_db(DB_CATALOG);

	    $result = mysql_query("select matricule, club, nom_prenom, sexe, date_naiss,

        elo_calcul, part_calcu from playernew where matricule = ".$playerId);

	    $record = mysql_fetch_assoc($result);

	    $player = new Player;

	    $player->club_id = $record['club'];

	    $player->player_key = $record['matricule'];

	    $player->player_name = $record['nom_prenom'];

	    $player->elo = $record['elo_calcul'];

        if ( isset($_SESSION['players']) && isset($row) ) {

        	$players = $_SESSION['players'];

            if (count($players) >= $row) {

				$players[$row-1] = $player;

	        	$_SESSION['players'] = $players;

            }

        }

	    return $player;

    }

    return null;

}



function getPlayerName() {

	$player = loadPlayer();

    return $player->player_name;

}



function getPlayerElo() {

	$player = loadPlayer();

    return $player->elo;

}



function getPlayerClub() {

	$player = loadPlayer();

    return $player->club_id;

}

?>

<response>

  <method>getPlayer</method>

  <name><?php echo getPlayerName()?></name>

  <elo><?php echo getPlayerElo()?></elo>

  <club><?php echo getPlayerClub()?></club>

</response>